package com.uzai.console.web.zombiepan;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.groupsendjob.GroupSendJobIdDto;
import com.uzai.console.dto.zombiefan.zombiefantask.ZombieFanTaskDto;
import com.uzai.console.dto.zombiefan.zombiefantask.ZombieFanTaskIdDto;
import com.uzai.console.dto.zombiefan.zombiefantask.ZombieFanTaskIdListDto;
import com.uzai.console.dto.zombiefan.zombiefantask.ZombieFanTaskQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.sysmaterial.SysMaterialService;
import com.uzai.console.service.zombiefan.ZombieFanTaskService;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.sysmaterial.UploadFileVo;
import com.uzai.console.vo.zombiefan.zombiefantask.ZombieFanTaskVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 清理僵尸粉任务
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "清理僵尸粉任务",tags = "僵尸粉|清理僵尸粉任务")
@ApiSort(31)
@RestController
public class ZombieFanTaskController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ZombieFanTaskController.class);

    @Autowired
    private ZombieFanTaskService zombiefantaskService;
    @Autowired
    private SysMaterialService sysMaterialService;

    @ApiOperation(value = "分页查询清理僵尸粉任务列表", notes = "分页查询清理僵尸粉任务列表", response = ZombieFanTaskVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/zombiefantask/findByPage")
    public Object findZombieFanTaskPage(@RequestBody ZombieFanTaskQuery zombiefantaskQuery){
        return zombiefantaskService.findZombieFanTaskList(zombiefantaskQuery);
    }

    @ApiOperation(value = "查询清理僵尸粉任务详情", notes = "查询清理僵尸粉任务详情", response = ZombieFanTaskVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/zombiefantask/findById")
    public Object findZombieFanTask(@RequestBody ZombieFanTaskIdDto zombiefantaskIdDto){
        return zombiefantaskService.findZombieFanTask(zombiefantaskIdDto);
    }

    @SystemLogType(model = SystemModelEnum.ZombieFanTask, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加清理僵尸粉任务", notes = "添加清理僵尸粉任务")
    @ApiOperationSupport(order = 3)
    @PostMapping("/zombiefantask/add")
    public Object addZombieFanTask(@RequestBody ZombieFanTaskDto zombiefantaskDto){
        zombiefantaskService.addZombieFanTask(zombiefantaskDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.GroupSendJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "开启清理僵尸粉任务", notes = "开启清理僵尸粉任务")
    @ApiOperationSupport(order = 4)
    @PostMapping("/zombiefantask/start")
    public Object startGroupSendJob(@RequestBody ZombieFanTaskIdDto zombiefantaskIdDto){
        zombiefantaskService.startZombieFanTask(zombiefantaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.GroupSendJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量开启清理僵尸粉任务(只能开启未开始和已暂停任务)", notes = "批量开启清理僵尸粉任务(只能开启未开始和已暂停任务)")
    @ApiOperationSupport(order = 4)
    @PostMapping("/zombiefantask/start/batch")
    public Object batchStartGroupSendJob(@RequestBody ZombieFanTaskIdListDto zombiefantaskIdListDto){
        zombiefantaskService.batchStartGroupSendJob(zombiefantaskIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.GroupSendJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "暂停清理僵尸粉任务", notes = "暂停清理僵尸粉任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/zombiefantask/pause")
    public Object pauseGroupSendJob(@RequestBody ZombieFanTaskIdDto zombiefantaskIdDto){
        zombiefantaskService.pauseZombieFanTask(zombiefantaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.GroupSendJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量暂停清理僵尸粉任务", notes = "批量暂停清理僵尸粉任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/zombiefantask/pause/batch")
    public Object batchPauseGroupSendJob(@RequestBody ZombieFanTaskIdListDto zombiefantaskIdListDto){
        zombiefantaskService.batchPauseGroupSendJob(zombiefantaskIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.ZombieFanTask, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除清理僵尸粉任务", notes = "删除清理僵尸粉任务")
    @ApiOperationSupport(order = 6)
    @PostMapping("/zombiefantask/delete")
    public Object deleteZombieFanTask(@RequestBody ZombieFanTaskIdDto zombiefantaskIdDto){
        zombiefantaskService.deleteZombieFanTask(zombiefantaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.ZombieFanTask, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "批量删除清理僵尸粉任务(只能删除完成状态)", notes = "批量删除清理僵尸粉任务(只能删除完成状态)")
    @ApiOperationSupport(order = 7)
    @PostMapping("/zombiefantask/delete/batch")
    public Object batchDeleteZombieFanTask(@RequestBody ZombieFanTaskIdListDto zombieFanTaskIdListDto){
        zombiefantaskService.batchDeleteZombieFanTask(zombieFanTaskIdListDto);
        return true;
    }


    @ApiOperation(value = "查询机器人下拉列表(过滤掉已经配置了清理僵尸粉任务的机器人)", notes = "查询机器人下拉列表(过滤掉已经配置了清理僵尸粉任务的机器人)", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/zombiefantask/findDeviceList")
    public Object findDeviceList(@RequestBody DeviceQuery deviceQuery) {
        return zombiefantaskService.findDeviceList(deviceQuery);
    }

    @SystemLogType(model = SystemModelEnum.GroupSendJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改清理僵尸粉任务", notes = "修改清理僵尸粉任务")
    @ApiOperationSupport(order = 8)
    @PostMapping("/zombiefantask/update")
    public Object updateGroupSendJob(@RequestBody ZombieFanTaskDto zombiefantaskDto){
        zombiefantaskService.updateZombieFanTask(zombiefantaskDto);
        return true;
    }

}
